-- death_bonus
-- Created by zhuangsl
-- 死亡时给予玩家奖励

return {
    apply = function(prop, baseValue)
        -- 提升的值
        return prop[3];
    end,

    -- 怪物死亡后触发
    trigger = function(who, prop)
        -- 不是怪物
        if who.type ~= OBJECT_TYPE_MONSTER then
            return;
        end

        -- 概率掉落
        if DungeonM.getRandSeed("death_bonus") % 1000 >= prop[3] then
            return;
        end

        local classId;
        if prop[2] == "jewel" then
            classId = FormulaM.invoke("FETCH_PROP_RANDOM_BONUS", prop[2]);
        else
            classId = tonumber(prop[2]);
        end

        -- 奖励
        local bonus = {1, classId, 1};
        BonusM.doBonus(bonus, "death_bonus");

        -- 抛出通用建筑奖励事件
        EventMgr.fire(event.COMM_BUILDING_BONUS, {
            ["pos"]   = who:getPos(),
            ["bonus"] = { ["bonus"] = bonus },
            ["remainGrid"] = true,
        });
    end,

    record = function(target, prop, path)
        return false;
    end
};